#define _CRT_SECURE_NO_WARNINGS 1


#include<unordered_map>
#include<string>
#include<iostream>

using namespace std;

bool Func(string& s)
{
	int count[26] = { 0 };

	for (auto& e : s)
	{
		count[e - 'A']++;
	}

	for (auto& e : count)
	{
		if (e == 0)
		{
			return false;
		}
	}

	return true;
}

int main()
{
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	unordered_map<char, char> hash;

	if (!Func(s2))
	{
		cout << "Failed" << endl;
		return 0;
	}

	for (int i = 0; i < s1.size(); i++)
	{
		if (hash.count(s1[i]) && s2[i] != hash[s1[i]])
		{
			cout << "Failed" << endl;
			return 0;
		}

		hash[s1[i]] = s2[i];
	}

	for (auto& e : s3)
	{
		cout << hash[e];
	}
	cout << endl;

	return 0;
}